return t('Allows administrators to customize the site navigation menu.');
case 'admin/menu':
return t('<p>Select an operation from the list to move, change, or delete a menu item.</p>');
case 'admin/menu/menu/add':
return t('<p>Enter the name for your new menu. Remember to enable the newly created block in the %blocks administration page.</p>', array('%blocks' => l(t('blocks'), 'admin/block')));
case 'admin/menu/item/add':
return t('<p>Enter the title, path, position and the weight for your new menu item.</p>');
}
}
/**
* Implementation of hook_block().
*/
function menu_block($op = 'list', $delta = 0) {
$menu = menu_get_menu();
if ($op == 'list') {
$blocks = array();
foreach ($menu['items'][0]['children'] as $mid) {
// Default "Navigation" block is handled by user.module.
db_query('UPDATE {menu} SET type = %d WHERE mid = %d', $type, $mid);
drupal_set_message(t('Menu item disabled.'));
drupal_goto('admin/menu');
}
/**
* Menu callback; dispatch to the appropriate menu item edit function.
*/
function menu_edit_item($mid = 0) {
$op = $_POST['op'];
$edit = $_POST['edit'];
$output = '';
switch ($op) {
case t('Submit'):
menu_edit_item_validate($edit);
if (!form_get_errors()) {
menu_edit_item_save($edit);
drupal_goto('admin/menu');
}
$output .= menu_edit_item_form($edit);
break;
default:
if ($mid > 0) {
$item = db_fetch_object(db_query('SELECT * FROM {menu} WHERE mid = %d', $mid));
$edit['mid'] = $item->mid;
$edit['pid'] = $item->pid;
$edit['path'] = $item->path;
$edit['title'] = $item->title;
$edit['description'] = $item->description;
$edit['weight'] = $item->weight;
$edit['type'] = $item->type;
}
else {
$edit['mid'] = 0; // In case a negative ID was passed in.
$edit['pid'] = 1; // default to "Navigation" menu.
$edit['type'] = MENU_CUSTOM_ITEM;
}
$output .= menu_edit_item_form($edit);
}
print theme('page', $output);
}
/**
* Present the menu item editing form.
*/
function menu_edit_item_form($edit) {
$menu = menu_get_menu();
$form .= form_textfield(t('Title'), 'title', $edit['title'], 60, 128, t('The name to display for this link.'), NULL, TRUE);
if ($edit['pid'] == 0) {
// Display a limited set of fields for menus (not items).
$form .= form_hidden('path', '');
$form .= form_hidden('pid', 0);
$form .= form_hidden('weight', 0);
}
else {
$form .= form_textfield(t('Description'), 'description', $edit['description'], 60, 128, t('The description displayed when hovering over a menu item.'));
$path_description = t('The Drupal path this menu item links to.');
$path_description .= "\n". t('Since a menu item "%old" already exists for "%path", this menu item is shortcut to that location.', array('%old' => l($old_item['title'], 'admin/menu/item/edit/'. $old_mid), '%path' => $edit['path']));
$form .= form_checkbox(t('Expanded'), 'expanded', 1, ($edit['type'] & MENU_EXPANDED), t('If selected and this menu item has children, the menu will always appear expanded.'));
// Generate a list of possible parents (not including this item or descendants).
$form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'));
}
$form .= form_submit(t('Submit'));
$form .= form_hidden('mid', $edit['mid']);
// Always enable menu items (but not menus) when editing them.
drupal_set_message(t('Created new menu item %title.', array('%title' => theme('placeholder', $edit['title']))));
if (array_key_exists($edit['path'], $menu['path index'])) {
$old_mid = $menu['path index'][$edit['path']];
$old_item = $menu['items'][$old_mid];
drupal_set_message(t('Since a menu item %old already exists for %path, this new menu item was created as a shortcut to that location.', array('%old' => l(theme('placeholder', $old_item['title']), 'admin/menu/item/edit/'. $old_mid, array(), NULL, NULL, FALSE, TRUE), '%path' => theme('placeholder', $edit['path']))));
}
}
}
/**
* Present the menu tree, rendered along with links to edit menu items.